<?php
namespace app\index\Controller;
use think\Controller;
use app\index\model\Build as Bu;
use app\index\controller\commom;
class Build extends Common
{
	public function index()
	{
		return view('list');
	}
	public function list()
	{
		$bu = new Bu();
		$list = $bu->list();
		return view("list",["list"=>$list]);
	}
	public function add(){
        $bu = new Bu();
        if(input("?param.sub")){
            $file = request()->file('image');
            if($file){
                $result = $bu->adds($file);
            }
            else{
                $result = $bu->add();
            }
            if($result){
                $this->success("添加成功","house/list");
            }else{
                $this->error("添加失败");
            }
        }
        else{
            return view("add",[]);
        }
    }
	public function update()
    {
        $bu = new Bu();
        $result = $bu->dan();
        if(input("?param.subm")) {
            $resultt= $bu
                ->updateById();
            if($resultt){
                $this->success("修改成功","house/list");
            }else{
                $this->error("修改失败");
            }
        }
        else {
            return view('update', ['list' => $result]);
        }
    }
	public function delete(){
        $id = input("param.id");
        $bu = new Bu();
        $result = $bu->deleteById($id);
        if($result){

            $this->success("删除成功","build/list");
        }else{
            $this->error("删除失败");
        }
    }
	
}
?>